package com.yoso.shop;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * @author yoso
 * @date 2021/12/12
 */
@Component
@Slf4j
public class ExitServer implements DisposableBean {
    @Override
    public void destroy() throws Exception {
        log.info("清理日志缓存文件..");
        File file = new File("../logs");
        if (file.exists() && file.isDirectory()){
            FileUtils.cleanDirectory(file);
            log.info("日志文件清理完成！");
        }else {
            log.info("无日志文件");
        }
    }
}
